<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>src\cmpage\model\page_ms.js</title>
  
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap.min.css">
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
</head>
<body class="yui3-smart">
 <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
               <a class="navbar-brand mainlogo" href="/static/doc/index.html">
             
            <img alt="" src="../assets/css/logo.png" title="">
            
                
          </a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                 <ul class="nav navbar-nav">
                    
                    <li><a href="/home/index/index">首页</a>
                    </li>
                    
                    <li><a href="/static/doc/index.html">文档</a>
                    </li>
                    
                    <li><a href="/admin/index/index">演示</a>
                    </li>
                    
                    <li><a href="/home/index/log">日志</a>
                    </li>
                    
                </ul>
               <div class="navbar-form navbar-right filterAPi" autocomplete="off">
                <input type="text" id='txtSearchAPI' class="form-control search-query" placeholder="Search for API" />
                 <ul id="filterList" class="filterItems dropdown-menu" role="menu"></ul>
                </div>
            </div>
        </div>
    </nav>
    <div id="sidebar">
    <h3>Modules/Classes</h3>
        <div id="api-tabview-filter">
            <input id='txtSearch' type="search" class="form-control" placeholder="Type to filter Modules/Classes">
        </div>
        <dl id="sidebar_list">
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/admin.controller.html">admin.controller</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/admin.controller.base.html">admin.controller.base</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.controller.code.html">admin.controller.code</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.controller.index.html">admin.controller.index</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.controller.mob.html">admin.controller.mob</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/admin.model.html">admin.model</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/admin.model.code.html">admin.model.code</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.code_list.html">admin.model.code_list</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.code_lookup.html">admin.model.code_lookup</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.groupuser.html">admin.model.groupuser</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.groupuser_add.html">admin.model.groupuser_add</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.log.html">admin.model.log</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.login.html">admin.model.login</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.privilege.html">admin.model.privilege</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.teamuser.html">admin.model.teamuser</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.teamuser_add.html">admin.model.teamuser_add</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.user.html">admin.model.user</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/cmpage.controller.html">cmpage.controller</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/cmpage.controller.base.html">cmpage.controller.base</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.controller.mob.html">cmpage.controller.mob</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.controller.module.html">cmpage.controller.module</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.controller.page.html">cmpage.controller.page</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.controller.utils.html">cmpage.controller.utils</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/cmpage.logic.html">cmpage.logic</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/cmpage.logic.page.html">cmpage.logic.page</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/cmpage.model.html">cmpage.model</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/cmpage.model.area.html">cmpage.model.area</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.base.html">cmpage.model.base</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.file_list.html">cmpage.model.file_list</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.page.html">cmpage.model.page</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.page_excel.html">cmpage.model.page_excel</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.page_lookup.html">cmpage.model.page_lookup</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.page_mob.html">cmpage.model.page_mob</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.utils.html">cmpage.model.utils</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.cmpage_global.html">cmpage.cmpage_global</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.cmpage_global_flow.html">cmpage.cmpage_global_flow</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/demo.model.html">demo.model</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/flow.model.proc_assign.html">flow.model.proc_assign</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.appr.html">cmpage.model.appr</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/flow.model.proc.html">flow.model.proc</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/flow.model.task.html">flow.model.task</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/flow.model.task_act.html">flow.model.task_act</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/flow.model.task_act_appr.html">flow.model.task_act_appr</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/flow.controller.html">flow.controller</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/flow.controller.act.html">flow.controller.act</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/flow.controller.base.html">flow.controller.base</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/flow.controller.proc.html">flow.controller.proc</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/flow.controller.task.html">flow.controller.task</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/flow.controller.task_act.html">flow.controller.task_act</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/flow.model.html">flow.model</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/flow.model.act.html">flow.model.act</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/flow.model.act_path.html">flow.model.act_path</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
        </dl>
</div>
   
    <div class="stdoc-content">
        <!--     <form id="options-form" class="form-inline pull-right">
        Show:
        <label for="api-show-inherited" class="checkbox">
            <input type="checkbox" id="api-show-inherited" checked>
            Inherited
        </label>

        <label for="api-show-protected" class="checkbox">
            <input type="checkbox" id="api-show-protected">
            Protected
        </label>

        <label for="api-show-private" class="checkbox">
            <input type="checkbox" id="api-show-private">
            Private
        </label>
        <label for="api-show-deprecated" class="checkbox">
            <input type="checkbox" id="api-show-deprecated">
            Deprecated
        </label>

    </form>

 -->
        <div class="apidocs">
            <div id="docs-main">
                <div class="content">
                    <div class="page-header">
    <h1>src\cmpage\model\page_ms.js <small>File</small></h1>
</div>

<div class="file">
    <pre class="prettyprint linenums" id='src_code'>
&#x27;use strict&#x27;;
// +----------------------------------------------------------------------
// | CmPage [ 通用页面框架 ]
// +----------------------------------------------------------------------
// | Licensed under the Apache License, Version 2.0
// +----------------------------------------------------------------------
// | Author: defans &lt;defans@sina.cn&gt;
// +----------------------------------------------------------------------

/**
 * page_rec model 实现主从表页面的编辑和查看
 */
import CMPage from &#x27;./page_mob.js&#x27;;

export default class extends CMPage {

    htmlGetTabs(){
        //debug(this.mod,&#x27;page_ms.htmlGetTabs - this.mod&#x27;);
        if(this.mod.editID ==0 || think.isEmpty(this.mod.c_module_slave.modulename))  return &#x27;&#x27;;
        let html =[];
        html.push( &#x60;    &lt;div id=&quot;rec${this.mod.c_modulename}Div&quot; &gt;
            &lt;fieldset&gt;
            &lt;legend&gt;-&lt;/legend&gt;
            &lt;ul class=&quot;nav nav-tabs&quot; role=&quot;tablist&quot;&gt;&#x60;);

        // for(let tab of this.mod.c_module_slave){
        //     html.push(&#x60;&lt;li ${ tabs.indexOf(tab) ===0 ? &quot;class=active&quot;:&quot;&quot;}&gt;&lt;a href=&quot;#page${tab.modulename}&quot; role=&quot;tab&quot; data-toggle=&quot;tab&quot;&gt;${tab.title}&lt;/a&gt;&lt;/li&gt;&#x60;);
        // }
        //暂时考虑一个TAB的情况
        let tab = this.mod.c_module_slave;
        debug(tab,&#x27;page_ms.htmlGetTabs - tab&#x27;);
        html.push(&#x60;&lt;li &quot;class=active&quot;&gt;&lt;a href=&quot;#page${tab.modulename}&quot; role=&quot;tab&quot; data-toggle=&quot;tab&quot;&gt;${tab.title}&lt;/a&gt;&lt;/li&gt;&#x60;);

        html.push(&#x60;&lt;/ul&gt; &lt;!-- Tab panes --&gt; &lt;div class=&quot;tab-content&quot;&gt;&#x60;);

        // for(let tab of this.mod.c_module_slave){
        //     html.push(&#x60;&lt;div class=&quot;tab-pane fade ${tabs.indexOf(tab) ==0 ? &quot;active in&quot;:&quot;&quot;}&quot; id=&quot;page${tab.modulename}&quot;  name=&quot;page${tab.modulename}&quot;
        //         data-url=&quot;/cmpage/page/list?modulename=${tab.modulename}&amp;${tab.key}=${this.mod.editID}&amp;moduleOpen=div${think.isEmpty(this.mod.parmsUrl.readonly) ? &#x27;&#x27;:&#x27;&amp;readonly=1&#x27;}&quot;
        //         data-toggle=&quot;autoajaxload&quot;&gt;  &lt;/div&gt;&#x60;);
        // }
        html.push(&#x60;&lt;div class=&quot;tab-pane fade active in&quot; id=&quot;page${tab.modulename}&quot;  name=&quot;page${tab.modulename}&quot;
            data-url=&quot;/cmpage/page/list?modulename=${tab.modulename}&amp;${tab.key}=${this.mod.editID}&amp;moduleOpen=div${think.isEmpty(this.mod.parmsUrl.readonly) ? &#x27;&#x27;:&#x27;&amp;readonly=1&#x27;}&quot;
            data-toggle=&quot;autoajaxload&quot;&gt;  &lt;/div&gt;&#x60;);

        html.push(&#x27;&lt;/div&gt;   &lt;/fieldset&gt;   &lt;/div&gt;&#x27;);
        //debug(html,&#x27;page_ms.htmlGetTabs - html&#x27;);
        return html.join(&#x27; &#x27;);
    }

    /**
     * 取结果数据集，子类中重写本方法可以增加逻辑如：对结果集做进一步的数据处理等
     * @method  getDataList
     * @return {object} 结果集数据包 {count:xxx, list:[{record}]}
     */
    async getDataList(){
        await super.getDataList();
        this.list.ids = [];     //主从表编辑页面不需要 上一条，下一条按钮
    }



    /**
     * 取查看页面的设置，组合成打印页面的HTML输出
     * @method  htmlGetPrint
     * @return {string} HTML页面片段
     */
      async htmlGetPrint() {
          let html = [];
          //主表部分
          html.push(await super.htmlGetPrint());
          if(this.mod.editID ==0 || think.isEmpty(this.mod.c_module_slave.modulename)){
              return html.join(&#x27;&#x27;);
          }
          //子表部分
          let module = await cmpage.model(&quot;cmpage/module&quot;);
          let md = await module.getModuleByName(this.mod.c_module_slave.modulename);
          debug(md,&#x27;page_ms.htmlGetPrint - md&#x27;);
          if(think.isEmpty(md.id))  return html.join(&#x27;&#x27;);
          let pageModel = cmpage.model(md.c_path);
          if(think.isEmpty(pageModel[&#x27;htmlGetQuery&#x27;]))  return html.join(&#x27;&#x27;);
          pageModel.mod = md;
          pageModel.mod.user = this.mod.user;
          pageModel.mod.c_pager = false;    //单页
          pageModel.mod.parmsUrl = {modulename:this.mod.c_module_slave.module};
          pageModel.mod.parmsUrl[this.mod.c_module_slave.key]=this.mod.editID;
          await pageModel.initPage();
          pageModel.modQuerys = await module.getModuleQuery(md.id);
          pageModel.modCols = await module.getModuleCol(md.id);
          await pageModel.getDataList();
          html.push(&#x27;&lt;table class=&quot;printTable&quot; style=&quot;BORDER-COLLAPSE:collapse; margin-top:-1px;&quot; bordercolor=&quot;#000000&quot; cellSpacing=0 width=&quot;100%&quot; align=&quot;center&quot; bgcolor=&quot;#FFFFFF&quot; border=&quot;1&quot;&gt;&#x27;);
          //标题
          for(let col of pageModel.modCols){
              if(col.c_isview)  html.push(&#x60;&lt;td class=&quot;td4&quot;&gt;${col.c_name}&lt;/td&gt;&#x60;);
          }
          //数据行
          for(let item of pageModel.list.data){
              html.push(&#x27;&lt;tr&gt;&#x27;);
              for(let col of pageModel.modCols){
                  if(col.c_isview){
                      html.push(&#x60;&lt;td style=&quot;${col.c_style}&quot; &gt;&#x60;);
                      if (item[pageModel.pk] !== 0 ) {
                          if (!think.isEmpty(col.c_format)) {
                              if (col.c_coltype === &quot;decimal&quot;) {
                                  html.push(cmpage.formatNumber(item[col.c_column], {pattern: col.c_format}));
                              } else if(col.c_coltype === &quot;timestamp&quot; || col.c_coltype === &quot;date&quot;) {
                                  html.push(cmpage.datetime(item[col.c_column], col.c_format));
                              }
                          } else if (col.c_type === &quot;checkbox&quot;) {
                              html.push(&#x60;&lt;input type=&quot;checkbox&quot;  data-toggle=&quot;icheck&quot; value=&quot;1&quot; disabled  ${item[col.c_column] || item[col.c_column]===1 ? &quot;checked&quot; : &quot;&quot;} /&gt;&#x60;);
                          } else if (!think.isEmpty(item[col.c_column]) &amp;&amp; col.c_type === &quot;replace&quot; &amp;&amp; !(/^select/.test(col.c_memo))) {
                              let templete = cmpage.objPropertysReplaceToStr(col.c_memo, item);
                              html.push(await this.getReplaceText(item[col.c_column],templete));
                          } else if (col.c_type === &quot;html&quot;) {
                              let input = think.isEmpty(col.c_memo) ? item[col.c_column] : col.c_memo.replace(/#value#/ig,item[col.c_column]);
  //                            debug(input,page.htmlGetList - input.html);
                              html.push(input);
                          } else {
                              if (!think.isEmpty(col.c_column)) {
                                  html.push(item[col.c_column]);
                              }
                          }
                      }
                      html.push(&#x27;&lt;/td&gt;&#x27;)
                  }
              }
              html.push(&#x27;&lt;/tr&gt;&#x27;);
          }
          html.push(await pageModel.htmlGetListSumRow(false));  //合计
          html.push(&#x27;&lt;/table&gt;&#x27;);

          return html.join(&#x27;&#x27;);
      }


}

    </pre>
</div>

                </div>
            </div>
        </div>
    </div>
<a id="gotoTop" class='well well-small' href='#'>
    Top
</a>
<script src="../assets/vendor/jquery/jquery-1.8.2.min.js"></script>
<script src="../assets/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script src="../assets/js/config.js"></script>
<script src="../assets/js/doc.js"></script>
</body>
</html>
